package cate.game.server.schedule;

import cate.game.server.service.DebugService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.Resource;

@Slf4j
@Configuration
@EnableScheduling
public class ScheduleDemo {

    private static final String CORN = "55 0 15 ? * TUE";

    //@Async
    //@Scheduled(cron = CORN)
    public void t1() throws Exception {
        log.info("t1-begin");
        Thread.sleep(9_000);
        log.info("t1-end");
    }

    //@Async
    //@Scheduled(cron = CORN)
    public void t2() throws Exception {
        log.info("t2-begin");
        Thread.sleep(9_000);
        log.info("t2-end");
    }

    @Resource
    DebugService debugService;

    @Scheduled(fixedDelay = 6000, initialDelay = 3000)
    public void debugThread() {
        //debugService.debugThread();
    }
}
